{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "35609088-8283-426f-a313-80fd4b5c18c2",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 回测结果查看"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "50d26b82-6f44-4d95-bd23-fa01606d31c3",
   "metadata": {
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from chanlun.backtesting import backtest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "921761b5-7729-4b53-a705-898674fb88a7",
   "metadata": {
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 从保存的回测落地文件中加载数据\n",
    "save_file = './data/bk/a_strategy_a_single_allmmd_signal.pkl'\n",
    "BT = backtest.BackTest()\n",
    "BT.load(save_file)\n",
    "# 显示回测配置与结果\n",
    "BT.info()\n",
    "BT.result()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "71f57d6a-3075-4990-ba2f-940b08cf865c",
   "metadata": {
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 回测数据展示\n",
    "BT.backtest_charts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3030af77-4801-4bac-adb4-f5f1e14c3787",
   "metadata": {
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 显示历史持仓\n",
    "#设置显示全部行，不省略\n",
    "pd.set_option('display.max_rows',None)\n",
    "#设置显示全部列，不省略\n",
    "pd.set_option('display.max_columns',None)\n",
    "\n",
    "# 显示指定标的的持仓\n",
    "BT.positions()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "abf97517-55c7-4147-bf79-9fa8d21ac24e",
   "metadata": {
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 显示标的周期的图标\n",
    "BT.show_charts(BT.codes[0], BT.frequencys[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7064f216-34b9-4e4a-996a-1c8660084117",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}